#pragma once

namespace HW2
{
	struct Color
	{

		double r, g, b;

		double alpha;
		// alpha is not covered by color methods

		Color(double r = 0, double g = 0, double b = 0, double alpha = 0) : r(r), g(g), b(b), alpha(alpha) {}

		Color operator*(double k) { return Color(r*k,g*k,b*k); }

		Color operator+(Color c) const{
			Color tmp(r+c.r,g+c.g,b+c.b);
			return tmp;
		}


		Color operator-(Color& c) const{
			Color tmp(r-c.r,g-c.g,b-c.b);
			return tmp;
		}
		Color operator*(Color c) const
		{
			Color tmp(r*c.r,g*c.g,b*c.b);
			return tmp;

		}

		void interpolate(Color c)
		{
			double a = c.alpha;
			if(a == 0)
				*this = c;
			*this = (*this * a) + c * (1-a);
			alpha = 0;

		}

		void normalizColor(){
			if (r < 0){
				r= 0;}
			if (r > 255){
				r=255;}
			if (g < 0){
				g= 0;}
			if (g > 255){
				g=255;}
			if (b < 0){
				b= 0;}
			if (b > 255){
				b=255;}
			//return *this;
		}

		void operator=(Color c){
			r = c.r;
			g = c.g;
			b = c.b;
		}

	};
}

